package com.xposed.aliproxy.rxjavademo.looper;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.xposed.aliproxy.rxjavademo.R;
import com.xposed.aliproxy.rxjavademo.looper.util.LooperUtil;

/**
 * Created by Su on 2019/1/7.
 */
public class PollingActivity extends AppCompatActivity implements View.OnClickListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_polling);
        findViewById(R.id.tv_simple).setOnClickListener(this);
        findViewById(R.id.tv_advance).setOnClickListener(this);

        LooperUtil.initLooper();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_simple:
                LooperUtil.startSimplePolling(1000);
                break;
            case R.id.tv_advance:
                LooperUtil.startAdvancePolling();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LooperUtil.clear();
    }

}
